import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';

import { markRaw } from 'vue';
// import { DictEnum } from '@vben/constants';
// import { VbenIcon } from '@vben/icons';
// import { getPopupContainer } from '@vben/utils';
// import { SensitiveText } from '#/components/text';

// import { Tag } from 'ant-design-vue';
// import { z } from '#/adapter/form';
// import { getDictOptions } from '#/utils/dict';
// import { renderDict } from '#/utils/render';
import GroupUserSelect from './group-user-select.vue';

export const querySchema: FormSchemaGetter = () => [
  {
    component: 'Input',
    fieldName: 'contactName',
    label: '联系人',
  },
  {
    component: 'Input',
    fieldName: 'contactMobile',
    label: '联系人电话',
  },
  {
    component: 'Input',
    fieldName: 'driverMobile',
    label: '司机电话',
  },
  {
    component: 'Input',
    fieldName: 'driverMobile',
    label: '车牌号',
  },
];

export const columns: VxeGridProps['columns'] = [
  // { type: 'checkbox', width: 60 },
  {
    title: '联系人',
    field: 'contactName',
    width: 120,
  },
  {
    title: '联系人电话',
    field: 'contactMobile',
    width: 160,
  },
  {
    title: '司机姓名',
    field: 'driverName',
    width: 130,
  },
  {
    title: '司机电话',
    field: 'driverMobile',
    width: 160,
  },
  {
    title: '车牌号',
    field: 'plateNumber',
    width: 130,
  },
  {
    title: '乘坐人数',
    field: 'takeNumber',
    width: 130,
  },
  {
    title: '出发地址',
    field: 'startAddress',
    width: 380,
    slots: {
      default: ({ row }) => {
        return (
          <span>
            {row.startProvinceName}
            {row.startCityName}
            {row.startDistrictName}
            {row.startAddress}
          </span>
        );
      },
    },
  },
  {
    title: '出发时间',
    field: 'startTime',
    width: 170,
  },
  {
    title: '返程地址',
    field: 'returnAddress',
    width: 380,
    slots: {
      default: ({ row }) => {
        return (
          <span>
            {row.returnProvinceName}
            {row.returnCityName}
            {row.returnDistrictName}
            {row.returnAddress}
          </span>
        );
      },
    },
  },
  {
    title: '返程时间',
    field: 'returnTime',
    width: 170,
  },
  {
    title: '备注',
    field: 'remark',
    width: 180,
    showOverflow: true,
  },
  {
    title: '创建时间',
    field: 'createTime',
    width: 170,
  },
  {
    field: 'action',
    fixed: 'right',
    slots: { default: 'action' },
    title: '操作',
    width: 200,
  },
];

export const modalSchema: FormSchemaGetter = () => [
  {
    label: 'ID',
    fieldName: 'id',
    component: 'Input',
    dependencies: {
      show: () => false,
      triggerFields: [''],
    },
  },
  {
    label: '巴士任务里的数据ID',
    fieldName: 'busId',
    component: 'Input',
    dependencies: {
      show: () => false,
      triggerFields: [''],
    },
  },
  {
    label: '联系人',
    fieldName: 'registerId',
    component: markRaw(GroupUserSelect),
    rules: 'required',
  },
  // {
  //   label: '联系人电话',
  //   fieldName: 'contactMobile',
  //   component: 'Input',
  //   rules: 'required',
  // },
  {
    label: '司机姓名',
    fieldName: 'driverName',
    component: 'Input',
    rules: 'required',
  },
  {
    label: '司机电话',
    fieldName: 'driverMobile',
    component: 'Input',
    rules: 'required',
  },
  {
    label: '车牌号',
    fieldName: 'plateNumber',
    component: 'Input',
    rules: 'required',
  },
  {
    label: '乘坐人数',
    fieldName: 'takeNumber',
    component: 'Input',
    rules: 'required',
  },
  {
    component: 'DatePicker',
    componentProps: {
      format: 'YYYY-MM-DD HH:mm:ss',
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
    fieldName: 'startTime',
    label: '出发时间',
    rules: 'selectRequired',
  },
  {
    component: 'AddressCascader',
    fieldName: 'startAddressMap',
    label: '出发地区',
    defaultValue: [],
    rules: 'selectRequired',
    componentProps: {
      isAbroad: 0,
    },
  },
  {
    label: '出发详细地址',
    fieldName: 'startAddress',
    component: 'Input',
    rules: 'required',
  },
  {
    component: 'DatePicker',
    componentProps: {
      format: 'YYYY-MM-DD HH:mm:ss',
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
    fieldName: 'returnTime',
    label: '返程时间',
  },
  {
    component: 'AddressCascader',
    fieldName: 'returnAddressMap',
    label: '返程地区',
    defaultValue: [],
    componentProps: {
      isAbroad: 0,
    },
  },
  {
    label: '返程详细地址',
    fieldName: 'returnAddress',
    component: 'Input',
  },
  {
    label: '备注',
    fieldName: 'remark',
    component: 'Textarea',
    componentProps: {
      autoSize: { minRows: 3 },
    },
  },
];
